//
//  LHRecommendCityHomePageViewController.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-15.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendCityHomePageViewController.h"
#import "LHRecommendCityHomePageView.h"
#import "LHRecommendCityHomePageCollectionView.h"
#import "LHRecommendSightViewController.h"
#import "LHRecommendRestaurantViewController.h"
#import "LHRecommendHotelViewController.h"
#import "MyNavgationView.h"
#import "LHRecommendSightDetailViewController.h"


@interface LHRecommendCityHomePageViewController ()<jumpToSightDetailViewDelegate>



@end

@implementation LHRecommendCityHomePageViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:0.871 green:0.962 blue:0.965 alpha:1.000];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self createRecommendCityHomePage];
    
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBarHidden = YES;
    
    [self createNavigation];

    
}

// 创建自定义导航栏
- (void)createNavigation
{
    MyNavgationView *myNaView = [[MyNavgationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    
    [myNaView creatTitle:self.cityName];
    
    myNaView.leftTarget = self;
    myNaView.leftAction = @selector(backToRecommendCitysController);
    
    [myNaView creatLeftButtonWithImage:@"btn_nav_back"];
    
    
    
    [self.view addSubview:myNaView];
    
    [myNaView release];
    
}

- (void)backToRecommendCitysController
{
    [self.navigationController popViewControllerAnimated:YES];
}


/**
 *  创建推荐城市主页
 */
- (void)createRecommendCityHomePage
{
    // 创建scrollView
    UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    
    myScrollView.contentSize = CGSizeMake(0, self.view.frame.size.height / 2  + 60  + (self.view.frame.size.width + 160));
    
    myScrollView.backgroundColor = [UIColor colorWithRed:0.871 green:0.962 blue:0.965 alpha:1.000];
    
    myScrollView.showsHorizontalScrollIndicator = YES;
    
    [self.view addSubview:myScrollView];
    
    [myScrollView release];
    
    
    // 创建view
    LHRecommendCityHomePageView *cityHomePageView = [[[LHRecommendCityHomePageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 2 + 60)] autorelease];
    
    cityHomePageView.city_arr = self.city_Arr;
    
    [cityHomePageView.recommendSight addTarget:self action:@selector(clickedRecommendSight) forControlEvents:UIControlEventTouchUpInside];
    
    [cityHomePageView.recommendRes addTarget:self action:@selector(clickedRecommendRes) forControlEvents:UIControlEventTouchUpInside];
    
    [myScrollView addSubview:cityHomePageView];
    
    [cityHomePageView.recommendHotel addTarget:self action:@selector(clickedRecommendHotel) forControlEvents:UIControlEventTouchUpInside];
    
    // 创建collectionView
    LHRecommendCityHomePageCollectionView *cityHomePageCollection = [[[LHRecommendCityHomePageCollectionView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height / 2 + 164, self.view.frame.size.width, self.view.frame.size.height + 300) cityId:self.cityIDstr] autorelease];
    
    cityHomePageCollection.delegate = self;
    
    [myScrollView addSubview:cityHomePageCollection];
    
}

// 跳转到推荐景点详情页面
- (void)jumpToSightDetailViewWithIndexPath:(NSIndexPath *)indexPath sightArr:(NSMutableArray *)sightArr
{
    LHRecommendSightDetailViewController *recSightDetailView = [[LHRecommendSightDetailViewController alloc] autorelease];
    
    recSightDetailView.sightDetailModel = sightArr[indexPath.row];
    
    [self.navigationController pushViewController:recSightDetailView animated:YES];
}

/**
 *  推荐景点button点击方法
 */
- (void)clickedRecommendSight
{
    LHRecommendSightViewController *sightVC = [[[LHRecommendSightViewController alloc] init] autorelease];
    
    sightVC.cityIdStr2 = self.cityIDstr;
    
    
    [self.navigationController pushViewController:sightVC animated:YES];
    
    
}

/**
 *  推荐餐馆button点击方法
 */

- (void)clickedRecommendRes
{
    LHRecommendRestaurantViewController *reslVC = [[[LHRecommendRestaurantViewController alloc] init] autorelease];
    
    reslVC.cityId_res = self.cityIDstr;
    
    [self.navigationController pushViewController:reslVC animated:YES];
    
    
    
}

/**
 *  推荐旅店button点击方法
 */

- (void)clickedRecommendHotel
{
    LHRecommendHotelViewController *hotelVC = [[[LHRecommendHotelViewController alloc] init] autorelease];
    
    hotelVC.cityId_hotel = self.cityIDstr;
    
    [self.navigationController pushViewController:hotelVC animated:YES];
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
